home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / SFLI10.ZIP / VGA.INC < prev   
Encoding:
Text File  |  1996-02-19  |  2.8 KB  |  206 lines

  1.     IDEAL
  2.     P386
  3.     LOCALS
  4.  
  5. ;       HideCursor
  6. ;       Hides the hardware cursor
  7.  
  8. MACRO   HideCursor
  9.  
  10.     mov ah,3
  11.     mov bh,0
  12.     int 10h
  13.     or ch,00100000b
  14.     mov ah,1
  15.     int 10h
  16.  
  17. ENDM    HideCursor
  18.  
  19.  
  20. ;       ShowCursor
  21. ;       Restores the hardware cursor
  22.  
  23. MACRO   ShowCursor
  24.  
  25.         mov ah,3
  26.         mov bh,0
  27.         int 10h
  28.         and ch,11011111b
  29.         mov ah,1
  30.         int 10h
  31.  
  32. ENDM    ShowCursor
  33.  
  34.  
  35. ;       WaitRetrace
  36. ;       Waits for the VGA Vertical retrace to commence
  37.  
  38. MACRO   WaitRetrace
  39. LOCAL   @@Tst1,@@Tst2
  40.  
  41.     push dx                 ; Save DX
  42.     push ax                 ; Save AX
  43.     mov dx,3dah             ; VGA Stat port
  44. @@Tst1:
  45.     in al,dx
  46.     and al,8
  47.     jnz @@Tst1              ; Wait if retrace is active
  48.  
  49. @@Tst2:
  50.     in al,dx
  51.     and al,8
  52.     jz @@Tst2               ; Wait for the next retrace
  53.  
  54.     pop ax
  55.     pop dx
  56.  
  57. ENDM    WaitRetrace
  58.  
  59. ;       VGA
  60. ;       Sets VGA mode(13h)
  61.  
  62. MACRO   VGA
  63.  
  64.     push ax
  65.     mov ax,13h
  66.     int 10h
  67.     pop ax
  68.  
  69. ENDM    VGA
  70.  
  71. ;       Text25
  72. ;       Sets 80x25 mode
  73.  
  74. MACRO   Text25
  75.  
  76.     push ax
  77.     mov ax,3
  78.     int 10h
  79.     pop ax
  80.  
  81. ENDM    Text25
  82.  
  83. ;       ClrVGA
  84. ;       Clears the VGA Mem buffer
  85.  
  86. MACRO   ClrVGA
  87.  
  88.     push es
  89.     push di
  90.     push cx
  91.     push ax
  92.  
  93.     mov cx,16000
  94.     mov di,0a000h
  95.     mov es,di
  96.     mov di,0
  97.     mov eax,0
  98.     rep stosd               ; DWORD Store...faster...
  99.  
  100.     pop ax
  101.     pop cx
  102.     pop di
  103.     pop es
  104.  
  105. ENDM    ClrVGA
  106.  
  107. ;       SavePal
  108. ;       Saves the entire palette
  109. ;       ES:DI -> 768-byte RGB-buffer
  110.  
  111. MACRO   SavePal
  112.  
  113.     push dx
  114.     push cx
  115.     push ax
  116.  
  117.     mov dx,3c7h
  118.     mov al,0
  119.     out dx,al               ; Set Read mode
  120.  
  121.     mov cx,768
  122.     mov dx,3c9h
  123.     rep insb                ; Read 768 bytes
  124.  
  125.     pop ax
  126.     pop cx
  127.     pop dx
  128.  
  129. ENDM    SavePal
  130.  
  131. ;       SetPal
  132. ;       Set the entire palette
  133. ;       DS:SI -> 768-byte RGB-buffer
  134.  
  135. MACRO   SetPal
  136.  
  137.     push dx
  138.     push cx
  139.     push ax
  140.  
  141.     WaitRetrace             ; Wait for vertical Retrace
  142.  
  143.     mov dx,3c8h
  144.     mov al,0
  145.     out dx,al               ; Set Write mode
  146.  
  147.     mov cx,768
  148.     mov dx,3c9h
  149.     rep outsb                ; Write 768 bytes
  150.  
  151.     pop ax
  152.     pop cx
  153.     pop dx
  154.  
  155. ENDM    SetPal
  156.  
  157. ;       FadeOut
  158. ;       Fades entire buffer out one step
  159. ;       ES:DI -> 768-byte RGB-buffer
  160. ;       DS:SI -> 768-byte limit RGB-buffer
  161.  
  162. MACRO   FadeOut
  163. LOCAL   @@next,@@nodec
  164.  
  165.     pusha
  166.  
  167.     mov cx,768
  168. @@next:
  169.     mov al,[byte ds:si]
  170.     cmp al,[byte es:di]
  171.     je @@nodec
  172.     dec [byte es:di]
  173. @@nodec:
  174.     inc si
  175.     inc di
  176.     loop @@next
  177.  
  178.     popa
  179.  
  180. ENDM    FadeOut
  181.  
  182. ;       FadeIn
  183. ;       Fades entire buffer in one step
  184. ;       ES:DI -> 768-byte RGB-buffer
  185. ;       DS:SI -> 768-byte limit RGB-buffer
  186.  
  187. MACRO   FadeIn
  188. LOCAL   @@ne,@@nod
  189.  
  190.     pusha
  191.  
  192.     mov cx,768
  193. @@ne:
  194.     mov al,[byte ds:si]
  195.     cmp al,[byte es:di]
  196.     je @@nod
  197.     inc [byte es:di]
  198. @@nod:
  199.     inc si
  200.     inc di
  201.     loop @@ne
  202.  
  203.     popa
  204.  
  205. ENDM    FadeIn
  206.